﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using YArchitech.LIB;

namespace HYView
{
	public partial class SelectFloorForm : System.Windows.Forms.Form
	{
		public CheckedListBox ChklViewOrLevel
		{
			get
			{
				return this.chkList;
			}
		}

		public List<int> SelectedViewIndexs()
		{
			List<int> list = new List<int>();
			for (int i = 0; i < this.chkList.Items.Count; i++)
			{
				if (this.chkList.GetItemChecked(i))
				{
					list.Add(i);
				}
			}
			return list;
		}

		public SelectFloorForm()
		{
			this.InitializeComponent();
		}

		public SelectFloorForm(List<ViewPlan> views)
		{
			this.m_Views = views;
			this.InitializeComponent();
			for (int i = 0; i < this.m_Views.Count; i++)
			{
				ViewPlan viewPlan = this.m_Views[i];
				if (!viewPlan.IsTemplate)
				{
					this.chkList.Items.Add(viewPlan.Name);
					this.chkList.SetItemChecked(i, true);
				}
			}
		}

		public SelectFloorForm(List<Level> levels)
		{
			this.m_Levels = levels;
			this.InitializeComponent();
			for (int i = 0; i < this.m_Levels.Count; i++)
			{
				Level level = this.m_Levels[i];
				this.chkList.Items.Add(level.Name);
				this.chkList.SetItemChecked(i, true);
			}
		}

		private void btnSelAll_Click(object sender, EventArgs e)
		{
			for (int i = 0; i < this.chkList.Items.Count; i++)
			{
				this.chkList.SetItemChecked(i, true);
			}
		}

		private void btnSelNone_Click(object sender, EventArgs e)
		{
			for (int i = 0; i < this.chkList.Items.Count; i++)
			{
				this.chkList.SetItemChecked(i, false);
			}
		}

		private void btnSelContrary_Click(object sender, EventArgs e)
		{
			for (int i = 0; i < this.chkList.Items.Count; i++)
			{
				bool value = !this.chkList.GetItemChecked(i);
				this.chkList.SetItemChecked(i, value);
			}
		}

		private void SelectFloorForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			if (!string.IsNullOrEmpty(this.strFormCaption))
			{
				this.Text = this.strFormCaption;
			}
		}

		private List<ViewPlan> m_Views = new List<ViewPlan>();

		public string strFormCaption;

		private List<Level> m_Levels = new List<Level>();
	}
}
